// @ts-ignore
/* eslint-disable */
import { request } from '@/utils/request'

/** addProduct POST /api/product/add */
export async function addProductUsingPost(
  body: API.ProductAddDto,
  options?: { [key: string]: any }
) {
  return request<API.ResultLong_>('/api/product/add', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** addProductByBatch POST /api/product/add/batch */
export async function addProductByBatchUsingPost(
  body: API.ProductFetchDto,
  options?: { [key: string]: any }
) {
  return request<API.ResultBoolean_>('/api/product/add/batch', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** altStatus PUT /api/product/alter/status */
export async function altStatusUsingPut(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.altStatusUsingPUTParams,
  options?: { [key: string]: any }
) {
  return request<API.ResultBoolean_>('/api/product/alter/status', {
    method: 'PUT',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** delProduct DELETE /api/product/delete/${param0} */
export async function delProductUsingDelete(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.delProductUsingDELETEParams,
  options?: { [key: string]: any }
) {
  const { id: param0, ...queryParams } = params
  return request<API.ResultBoolean_>(`/api/product/delete/${param0}`, {
    method: 'DELETE',
    params: { ...queryParams },
    ...(options || {}),
  })
}

/** getProductById GET /api/product/get/${param0} */
export async function getProductByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getProductByIdUsingGETParams,
  options?: { [key: string]: any }
) {
  const { id: param0, ...queryParams } = params
  return request<API.ResultProduct_>(`/api/product/get/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  })
}

/** getProductVoById GET /api/product/get/vo/${param0} */
export async function getProductVoByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getProductVoByIdUsingGETParams,
  options?: { [key: string]: any }
) {
  const { id: param0, ...queryParams } = params
  return request<API.ResultProductVo_>(`/api/product/get/vo/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  })
}

/** uploadImage POST /api/product/image/upload */
export async function uploadImageUsingPost(
  body: {},
  file?: File,
  options?: { [key: string]: any }
) {
  const formData = new FormData()

  if (file) {
    formData.append('file', file)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<API.ResultString_>('/api/product/image/upload', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  })
}

/** listProductsByPage POST /api/product/page */
export async function listProductsByPageUsingPost(
  body: API.PageProductDto,
  options?: { [key: string]: any }
) {
  return request<API.ResultPageBeanProduct_>('/api/product/page', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** purchaseProduct POST /api/product/purchase */
export async function purchaseProductUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.purchaseProductUsingPOSTParams,
  options?: { [key: string]: any }
) {
  return request<API.ResultBoolean_>('/api/product/purchase', {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** recommendProducts POST /api/product/recommend */
export async function recommendProductsUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.recommendProductsUsingPOSTParams,
  options?: { [key: string]: any }
) {
  return request<API.ResultListProductVo_>('/api/product/recommend', {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** searchProducts POST /api/product/search */
export async function searchProductsUsingPost(
  body: API.SearchProductDto,
  options?: { [key: string]: any }
) {
  return request<API.ResultPageBeanProductVo_>('/api/product/search', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** updateProduct PUT /api/product/update */
export async function updateProductUsingPut(
  body: API.ProductUpdateDto,
  options?: { [key: string]: any }
) {
  return request<API.ResultBoolean_>('/api/product/update', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}
